/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.shooter;

/**
 *
 * @author Unni Vemanchery Mana
 * 
 * This class keeps monitoring the player position
 * and moves the bomber to player position.
 * Once the player position is identified, then it will send the bomber to
 * that place.
 * 
 * This class will place bomber in every 4 seconds. This initial time can be 
 * changed as the game play progresses
 */
public class GameTimer {
    
    private static long startTime = 0;
    
    private static ITimer timer ;
    
    private static int interVal = 4;
    
    public static boolean isExplosion = false;
    
    public static void start(ITimer aTimer){
      startTime = System.currentTimeMillis();
      timer     = aTimer;
    }
    
    public long getStartTimer() {
      return startTime;
    }
    
    public static void calculateDeltaTime(long gameTimer){
      long currTime = System.currentTimeMillis();
      long diff     = (currTime - startTime)/1000;
      if(diff >= interVal) {
         if(!isExplosion) {
         resetTimer();
         timer.execute();
         }
      }
    }

    public static void resetTimer(){
      startTime = System.currentTimeMillis();
    }
}
